package com.mhc.haval.manager.impl;

import com.mhc.haval.dal.mapper.ext.FuncExtMapper;
import com.mhc.haval.dal.model.FuncDO;
import com.mhc.haval.dal.query.FuncQuery;
import com.mhc.haval.manager.FuncManager;
import com.subaru.common.query.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


/**
 * Manager for Func.
 */

@Service
public class FuncManagerImpl implements FuncManager{

    
    @Autowired
    protected FuncExtMapper funcExtMapper;

    /**
     * query count by query condition.
     */
    @Override
    public int countByQuery(FuncQuery query){
        return funcExtMapper.countByQuery(query);
    }

    @Override
    public int countByQueryMap(Map queryMap){
        return funcExtMapper.countByQueryMap(queryMap);
    }

    /**
     * delete by query condition.
     */
    @Override
    public int deleteByQuery(FuncQuery query){
        return funcExtMapper.deleteByQuery(query);
    }

    /**
     * delete by primary key.
     */
    @Override
    public int deleteByPrimaryKey(FuncDO record){
        return funcExtMapper.deleteByPrimaryKey(record);
    }

    /**
     * insert selective.
     */
    @Override
    public long insertSelective(FuncDO record){
        return funcExtMapper.insertSelective(record);
    }

    /**
     * select by query condition.
     */
    @Override
    public List<FuncDO> selectByQuery(FuncQuery query){
        return funcExtMapper.selectByQuery(query);
    }

    /**
     * select by query condition with page.
    */
    @Override
    public PageResult<FuncDO> selectByQueryWithPage(FuncQuery query) {
        PageResult<FuncDO> result = new PageResult<FuncDO>();
        result.setPageSize(query.getPageSize());
        result.setPageNo(query.getPageNo());
        result.setTotalCount(this.countByQuery(query));
        result.setResult(this.selectByQuery(query));
        return result;
    }

    /**
     * select by primary key.
     */
    @Override
    public FuncDO selectByPrimaryKey(Long id){
        return funcExtMapper.selectByPrimaryKey(id);
    }

    /**
     * select func list by staff id.
     */
    @Override
    public List<FuncDO> selectByStaffId(Long staffId) {
        return funcExtMapper.selectByStaffId(staffId);
    }

    /**
     * select func list by role id.
     */
    @Override
    public List<FuncDO> selectByRoleId(Long roleId) {
        return funcExtMapper.selectByRoleId(roleId);
    }

    @Override
    public List<FuncDO> queryFuncListByCondition(Map queryMap) {return funcExtMapper.queryFuncListByCondition(queryMap); }

    /**
     * update by query condition selective.
     */
    @Override
    public int updateByQuerySelective( FuncDO record,  FuncQuery query){
        return funcExtMapper.updateByQuerySelective(record,  query);
    }

    /**
     * update by query condition.
     */
    @Override
    public int updateByQuery( FuncDO record,  FuncQuery query){

        return funcExtMapper.updateByQuery(record, query);
    }

    /**
     * update by primary key selective.
     */
    @Override
    public int updateByPrimaryKeySelective(FuncDO record){
        return funcExtMapper.updateByPrimaryKeySelective(record);
    }
}